Version 2.0 of the TCL introduced a new method in CApplication called ShowSplashScreen(). This method is called at startup in CApplication::DoRun(), prior to the program handling any AppleEvents. Although the Visual Architect can be used to create the code neccessary for a splash screen, it is much simpler for you to write your own by hand, especially if all you want to do is display a PICT resource for a number of seconds. This is especially true if you want to add a splash screen to projects you are converting from 1.1.3.
To use the code below, override ShowSplashScreen() in your own CApplication derived class, and then make sure the source file contains all of the code outlined below. Features of the code are: TCL 2.0 use of constructors with default arguments; moving the window offscreen prior to calling Select() & Prepare(), thus preventing the user at staring at a blank window for a second before the CPicture object can be drawn; ‘paranoid’ memory cleanup to make absolutely certain there are no memory leaks.
// TCL INCLUDES…
#include <CDecorator.h>
#include <CPicture.h>
#include <CWindow.h>
// EXTERN GLOBALS…
extern CDecorator *gDecorator;
void myCApplication::ShowSplashScreen(void)
{
const short kProcID = dBoxProc, // Window Manager window type = 1
kPicResID = 2000, // PICT resource ID
kPICTx = 250, // Width of PICT in pixels
kPICTy = 130; // Height "
const long kDuration = 120; // Delay for @ 2 secs ( = 120/60 )
CDirector *myDir = NULL; // TCL based object pointers...
CWindow *myWindow = NULL;
CPicture *myPicture = NULL;
Rect aRect = {0, 0, kPICTy, kPICTx};
long finalTick = 0;
myDir = new CDirector(this); // Create Bureaucrat & Window
myWindow = new CWindow(&aRect, false, kProcID, false, false, myDir);
myPicture = new CPicture(myWindow, myDir); // Create CPicture object